package com.tadpole.music.adapter.me;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.tadpole.music.R;
import com.tadpole.music.adapter.base.BaseAdapter;
import com.tadpole.music.bean.me.MoNiErrorBottomBean;
import com.tadpole.music.holder.base.BaseViewHolder;
import com.tadpole.music.holder.base.NoDataEmpty;
import com.tadpole.music.holder.me.MoNiErrorV2ViewHolder;
import com.tadpole.music.holder.me.ZhenTiWorkViewHolder;

import java.util.List;

/**
 * Created By 孙岩
 * on 2020/12/26
 */
public class MoNiErrorV2Adapter extends BaseAdapter {
    private Activity activity;
    private MoNiErrorV2ViewHolder moNiErrorV2ViewHolder;
    private OnItemClickListener onItemClickListener;
    private List<MoNiErrorBottomBean.DataBeanX.DataBean> list;

    public MoNiErrorV2Adapter(Activity activity, List<MoNiErrorBottomBean.DataBeanX.DataBean> list) {
        this.activity = activity;
        this.list = list;
    }


    @Override
    public BaseViewHolder createRelHolder(ViewGroup parent, int viewType) {
        if (list == null || list.size() == 0) {
            String empty = "NO_DATA";
            LayoutInflater layoutInflater = LayoutInflater.from(activity);
            View inflate = layoutInflater.inflate(R.layout.item_no_data, parent, false);
            NoDataEmpty noDataEmpty = new NoDataEmpty(inflate, empty);
            return noDataEmpty;
        } else {
            moNiErrorV2ViewHolder = new MoNiErrorV2ViewHolder(LayoutInflater.from(activity).inflate(R.layout.item_v2_moni_error, parent, false), onItemClickListener, list);
            return moNiErrorV2ViewHolder;
        }

    }

    @Override
    public int getRelItemCount() {
        return list == null || list.size() == 0 ? 1 : list.size();
    }

    @Override
    public void setOnItemClickListener(BaseAdapter.OnItemClickListener listener) {
        this.onItemClickListener = listener;
    }

    @Override
    public void setOnChildClickListener(BaseAdapter.OnChildClickListener listener) {

    }

    @Override
    public void setOnLongClickListener(BaseAdapter.OnLongClickListener listener) {

    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) {
        holder.init(position - mHeadViews.size());
    }
}
